package com.bgs.eat.login.controller;

import com.bgs.eat.config.CommonResult;
import com.bgs.eat.login.service.ShopLoginService;
import com.bgs.eat.userProtal.entity.UserProtalEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName ShopLoginController
 * @Description TODO
 * @Author lzy
 * @Date 2022/10/14 10:41
 **/
@RestController
@CrossOrigin
@RequestMapping("/shoplogin")
public class ShopLoginController {

    @Autowired
    ShopLoginService shopLoginService;

    /**
    * @Description 店铺根据账号登录
    * @Author lzy
    * @Date 2022/10/14 10:44
    * @Return com.bgs.eat.config.CommonResult
    * @param userName
    * @param password
    */
    @GetMapping("/loginByUserRequest")
    public CommonResult loginByUserRequest(String userName,String password){
        return shopLoginService.loginByUserRequest(userName,password);
    }

    /**
    * @Description 商家app 根据手机号登录/注册（门户展示）
    * @Author lzy
    * @Date 2022/10/17 8:39
    * @Return com.bgs.eat.config.CommonResult
    * @param phone
    * @param code
    * @param manner
    */
    @GetMapping("/loginByPhoneRequest")
    public CommonResult loginByPhoneRequest(String phone, String code,String manner) {
        return shopLoginService.loginByPhoneRequest(phone,code,manner);
    }

    /**
    * @Description 商家app发送验证码（门户展示）
    * @Author lzy
    * @Date 2022/10/17 8:49
    * @Return com.bgs.eat.config.CommonResult
    * @param phone
    */
    @GetMapping("/shopLoginGoCode")
    public CommonResult shopLoginGoCode(String phone) {
        return shopLoginService.shopLoginGoCode(phone);
    }

    /**
    * @Author G胖
    * @Description 商家app提现时绑定支付宝账号
    * @Date 2022-10-28 上午 10:50
    * @Return

    */
    @PostMapping("/bindApliyLoginName")
    public CommonResult bindApliyLoginName(@RequestBody UserProtalEntity userProtalEntity){
        return CommonResult.ok(shopLoginService.alipayLoginName(userProtalEntity));
    }

    /**
    * @Author G胖
    * @Description 查询商家是否绑定了支付宝账号
    * @Date 2022-10-28 下午 01:37
    * @Return com.bgs.eat.config.CommonResult

    */
    @GetMapping("/getShopLoginName")
    public CommonResult getShopLoginName(Integer id){
        return CommonResult.ok(shopLoginService.getShopLoginName(id));
    }
}
